package com.learn.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2025/01/23
 * @description
 */
@Controller
//@RequestMapping("/user") // 路径的公共前缀
public class SecondController {
    @RequestMapping({"/", "/index"})
    public String index() {
        return "index";
    }
//    @RequestMapping("/a?z")
//    @RequestMapping("/a*z")
    @RequestMapping("/z/**")
    public String ant() {
        return "first";
    }
    @RequestMapping("/first/{username}/{password}")
    public String restful(@PathVariable("username") String username,
                        @PathVariable("password") String password) {
        System.out.println(username + ": " + password);
        return "first";
    }
    @RequestMapping(value = "/method", method = {RequestMethod.POST})
    public String method() {
        return "first";
    }
//  必须有username和password参数
//    @RequestMapping(value = "/params", params = {"username", "password"})
//    不能有username，必须有password, username=&password=123也不行
//    @RequestMapping(value = "/params", params = {"!username", "password"})
//    username必须为admin 必须有和password参数
//    @RequestMapping(value = "/params", params = {"username=admin", "password"})
//    username必须有且不为admin 必须有和password参数
    @RequestMapping(value = "/params", params = {"username!=admin", "password"})
    public String params() {
        return "first";
    }
}